package test;

/**
 *
 * @author yakimovich
 */
public class CreateDropTables {

    /**
     * Create SQL for create tables.
     */
    public static StringBuilder CREATE_TABLES = new StringBuilder();
    /**
     * Create SQL for drop tables.
     */
    public static StringBuilder DROP_TABLES = new StringBuilder();

    static {
        CREATE_TABLES.append("CREATE TABLE ROLES(");
        CREATE_TABLES.append("ROLE_ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, ");
        CREATE_TABLES.append("NAME VARCHAR(20) NOT NULL UNIQUE, ");
        CREATE_TABLES.append("PRIMARY KEY (ROLE_ID));");

        CREATE_TABLES.append("CREATE TABLE USERS(");
        CREATE_TABLES.append("USER_ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, ");
        CREATE_TABLES.append("LOGIN VARCHAR(20) NOT NULL UNIQUE, ");
        CREATE_TABLES.append("PASSWORD CHAR(20) NOT NULL, ");
        CREATE_TABLES.append("EMAIL VARCHAR(60) NOT NULL UNIQUE, ");
        CREATE_TABLES.append("FIRST_NAME VARCHAR(20) NOT NULL, ");
        CREATE_TABLES.append("LAST_NAME VARCHAR(40) NOT NULL, ");
        CREATE_TABLES.append("BIRTHDAY DATE NOT NULL, ");
        CREATE_TABLES.append("ROLE_ID BIGINT NOT NULL, ");
        CREATE_TABLES.append("PRIMARY KEY (USER_ID), ");
        CREATE_TABLES.append("FOREIGN KEY (ROLE_ID) ");
        CREATE_TABLES.append("REFERENCES ROLES(ROLE_ID));");
    }
    

    static {
        DROP_TABLES.append("DROP TABLE IF EXISTS USERS; ");
        DROP_TABLES.append("DROP TABLE IF EXISTS ROLES; ");
    }
}
